/******************************************************************************
* This file is part of xn5106 platform,
* Copyright (c) 2009 HangZhou InfoStrong CO.,LTD. All rights reserved.
* This software may only be used under the terms of a valid, current,
* end user licence from InfoStrong.
* Nothing else gives you the right to use this software.   
*
* Name:   app_cust.c
* Desc:   application custom C file
* Author: Jerry
* Date:   2011-5-10
* Note:   
* History:
*
******************************************************************************/
#include "drv_all.h"
#include "os_api.h"
#include "sys_glb.h"
#include "plc_all.h"
#include "app_isdp.h"
#include "host_if.h"

#ifdef APP_SDK_FLG

#ifdef HOST_IF_ISDP_FLG			// IS-DP definitions
static BOOL app_cust_isdp_cmd_test( HostISDPLLHdr *p_isdp_hdr );
extern U8 isdp_cmd_pkg_build( HostISDPLLHdr *p_isdp_hdr, U8 ctrl, U8 *p_data, U8 data_len );

// Host communication application function list table
const ISDP_CMD_FUNC_OBJ_T c_app_cust_isdp_cmd_list[] = 
{
	APP_CUST_ISDP_CMD_TEST, app_cust_isdp_cmd_test,

	(ISDP_CMD_ID)0, NULL,
};
#endif

/*
* Function Name:
*   app_cust_plc_data_proc
* Description:
*   PLC data frame handle procedure
* Parameters:
*   U8* p_user_data: data pointer of dlt645 frame
*   U16 user_len: length of dlt645 frame
* Returns:
*   BOOL: func's status
* Author				Date 
*  Jerry				2011-5-10   
* Note:
*    
*/
BOOL app_cust_plc_data_proc( U8 *p_user_data, U16 user_len )
{
	return TRUE;
}

/*
* Function Name:
*   app_cust_ping_mt_proc
* Description:
*   Ping mt cust proc
* Parameters:
*   U8* p_mt_mac: Meter mac pointer(6B)
*   
* Returns:
*   BOOL: func's status
* Author				Date 
*  Jerry				2012-9-6   
* Note:
*    
*/
BOOL app_cust_ping_mt_proc( U8 *p_mt_mac, MT_DLT645_T mt_prot_type )
{

	return TRUE;
}

/*
* Function Name:
*   app_cust_plc_rsp_status
* Description:
*   PLC Send ACK or Error ID to app
* Parameters:
*   U32 status: 1--ok; 0--error
* Returns:
*   BOOL:
* Author				Date 
*  Jerry				2010-1-18   
* Note:
*    
*/
BOOL app_cust_plc_rsp_status( U32 status )
{
	return TRUE;
}

/*
* Function Name:
*   app_cust_uart_data_proc
* Description:
*   App UART data procedure
* Parameters:
*   U8* p_user_data: 
*   U16 user_len:
* Returns:
*   BOOL:
* Author				Date 
*  Jerry				2011-5-11   
* Note:
*    
*/
BOOL app_cust_uart_data_proc( U8 *p_user_data, U16 user_len )
{

	return TRUE;
}

#ifdef HOST_IF_ISDP_FLG			// IS-DP definitions
/*
* Function Name:
*   app_cust_isdp_cmd_test
* Description:
*   isdp cmd test
* Parameters:
*   HostISDPLLHdr* p_isdp_hdr: IS-DP LL header pointer
* Returns:
*   BOOL:
* Author				Date 
*  nicky				2011-07-01   
* Note: 
*   ISDP_CMD_IOT_NODE_RELAY_CTRL_DIR_SET 
*   PC-->Chip: test data
*   Chip-->PC: status(1B)
*/
static BOOL app_cust_isdp_cmd_test( HostISDPLLHdr *p_isdp_hdr )
{
	U8 snd_len;
	const U8 test_data[10]={0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09};
	
	IS_ASSERT( p_isdp_hdr != NULL );
	if ( NULL == p_isdp_hdr )
	{
		return FALSE;
	}

	p_isdp_hdr->m_len = 10;
	isOS_memcpy((U8*) p_isdp_hdr->m_data, \
			test_data, sizeof(test_data));
	snd_len = isdp_cmd_pkg_build( p_isdp_hdr,p_isdp_hdr->m_ctrl, \
		(U8 *) p_isdp_hdr->m_data, p_isdp_hdr->m_len );		
	
	// ----- Send Response data ----
	host_if_send((U8*) p_isdp_hdr, snd_len );

	return TRUE;
}
#endif

#endif


